home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 411 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.3 KB

  1. Path: newshost.lanl.gov!tanmoy
  2. From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Bitwise Operator, ~, Help
  5. Date: 05 Jan 1996 04:26:07 GMT
  6. Organization: Los Alamos National Laboratory
  7. Message-ID: <TANMOY.96Jan4212607@qcd.lanl.gov>
  8. References: <4bkhg7$4fd@berry.elite.net> <4bsf7r$pn0@spanky.pls.ov.com>
  9.     <4bt51o$7nc@news2.ios.com> <4cch26$9vv@caip.rutgers.edu>
  10. NNTP-Posting-Host: qcd.lanl.gov
  11. Mime-Version: 1.0
  12. Content-Type: text
  13. In-reply-to: halasz@caip.rutgers.edu's message of 2 Jan 1996 19:02:14 -0500
  14.  
  15. --text follows this line--
  16. In article <4cch26$9vv@caip.rutgers.edu> halasz@caip.rutgers.edu writes:
  17.    In article <4bt51o$7nc@news2.ios.com>, aldo@tribeca.ios.com (Aldo
  18. Di Domenico) writes 
  19.    > Almost...... but how does the compiler knows how many bits to operate 
  20.    > on?  Will a compiler that uses 5 bytes (or whatever) for an int return a 
  21.    > different value than one which uses 4 (doesn't sound too likely), or does 
  22.    > it all depend on the number of leading zero's that you use?
  23.  
  24.    It depends on the implicit type of the constant.  This type is alwais
  25.    one that one can declare a variable in (that is, the length of the
  26.    constant written in decimal, octonarie, or sedenarie digits is
  27.    irrelevant).  If no letter is uzed, decimal constants are signd and
  28.    binarie are not, and the length is of 'int'.  Otherwize the letters
  29.    "L" and "U" set its length and signedness.
  30.  
  31. Almost. To avoid later confusion, it should probably be mentioned that
  32. a long (or, where appropriate, unsigned long) is chosen if required to
  33. preserve the value. Similarly, decimal need not be signed: an unsigned
  34. will be chosen (even in preference to a longer type) if it will do. If
  35. unsigned long does not suffice, it is an error.
  36.  
  37.    In the givven example, if 'int' is 32 bits long, then both 0177 and  ~0177
  38.    are 32 bits long.
  39.  
  40. Cheers
  41. Tanmoy
  42. --
  43. tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
  44. Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
  45. Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
  46. <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
  47. internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
  48. fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
  49.